function filter(arr, fn) {
  let results = [];
  for (let i = 0; i < arr.length; i++) {
    if (fn(arr[i])) {
      results.push(arr[i])
    }
  }
  return results;
}
// 测试
let arr = [1, 4, 6, 8, 5, 5];
let result = filter(arr, (item) => {
  return item % 2 == 0;
})
console.log(result);